package com.zds.hj.poseidon.biz.dispatcher.credit.demo;

import com.zds.boot.common.utils.Ids;
import com.zds.boot.dispatch.annotation.DispatcherHandler;
import com.zds.boot.dispatch.comm.enums.ModuleNodeTypeEnum;
import com.zds.boot.dispatch.dto.BaseReqModel;
import com.zds.boot.dispatch.dto.BaseResultModel;
import com.zds.hj.poseidon.biz.dispatcher.credit.CreditCheckAbsHandler;
import com.zds.hj.poseidon.facade.dto.hpp.credit.CreditInfoEntityDto;
import com.zds.hj.product.facade.constant.ApplicationContainerConstant;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author duanhao
 * @Description 个人身份证上传
 * @Date 2023/6/6 10:08
 */
@DispatcherHandler(value = "UploadInfoHandler", desc = "个人身份证上传", applicationContainer = ApplicationContainerConstant.FRONT_END, nodeType = ModuleNodeTypeEnum.BUSINESS)
@Slf4j
public class UploadInfoHandler extends CreditCheckAbsHandler {
    @Override
    public void creditDoExecute(BaseReqModel params, BaseResultModel resultModel, CreditInfoEntityDto reqData, CreditInfoEntityDto dbData) {
        log.info("个人身份证上传入参: {}", reqData);
        dbData.setImgId(reqData.getImgId());
        dbData.setCardId(reqData.getCardId());
    }


    @Override
    public BaseResultModel doSection(BaseReqModel baseReqModel) {
        BaseResultModel baseResultModel = super.doSection(baseReqModel);
        Map<String, Object> map = new HashMap<>(2);
        map.put("imgId", Ids.gid());
        map.put("cardId", "51162213334232244");
        baseResultModel.setResult(map);
        return baseResultModel;
    }

    @Override
    public Object paramsFerry(Object o) {
        CreditInfoEntityDto dbDto = (CreditInfoEntityDto) o;
        CreditInfoEntityDto creditInfoEntityDto = new CreditInfoEntityDto();
        creditInfoEntityDto.setImgId(dbDto.getImgId());
        creditInfoEntityDto.setCardId(dbDto.getCardId());
        return creditInfoEntityDto;
    }

}
